﻿Imports System.Data.SqlClient

Public Class clsCATEGORIAS
    Public Function CREA_CATEGORIA(ByVal NOMBRE As String) As Integer
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand("sp_CATEGORIAS", cnConn)
        Command.CommandType = CommandType.StoredProcedure

        Command.Parameters.Add(New SqlParameter("@NOMBRE", SqlDbType.VarChar, 10))
        Command.Parameters("@NOMBRE").Value = NOMBRE
        Command.Parameters.Add(New SqlParameter("@NOMBRE_USUARIO", SqlDbType.VarChar, 100))
        Command.Parameters("@NOMBRE_USUARIO").Value = UsuarioActivo

        Try
            cnConn.Open()
            Dim rdBuscar As SqlDataReader = Command.ExecuteReader()

            If rdBuscar.Read() Then
                CREA_CATEGORIA = rdBuscar("RESULTADO")
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            CREA_CATEGORIA = -1
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try


    End Function
End Class
